﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Simple.Services;
using Simple.Services.System.QHSEViolationCategory.Models;

namespace Simple.WebApi.Controllers.System;

/// <summary>
/// 数据字典管理
/// </summary>
[Route("QHSEDictionary/[action]")]
[ApiController]
public class QHSEDictionaryController : ControllerBase
{
    private readonly QHSEDictionaryService _dictionaryService;

    public QHSEDictionaryController(QHSEDictionaryService dictionaryService)
    {
        _dictionaryService = dictionaryService;
    }

    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> List()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetAsync();
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    //[CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> Page([FromQuery] QHSEDictionaryPageInputModel model)
    {
        PageResultModel<QHSEDictionaryModel> data = await _dictionaryService.GetPageAsync(model);
        return AppResult.Status200OK(data: data);
    }
    /// <summary>
    /// 最顶级
    /// </summary>
    [HttpGet]
    //[CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> IndexPage([FromQuery] PageInputModel model)
    {
        PageResultModel<QHSEDictionaryModel> data = await _dictionaryService.GetIndexPageAsync(model);
        return AppResult.Status200OK(data: data);
    }
    /// <summary>
    /// 获取子集列表
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> GetDictionaryPage([FromQuery] PageInputModel model)
    {
        var data = await _dictionaryService.GetDictionaryPageAsync(model);
        return AppResult.Status200OK(data: data);
    }
    /// <summary>
    /// 新增
    /// </summary>
    [HttpPost]
    //[CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> Add([FromBody] QHSEDictionaryModel model)
    {
        await _dictionaryService.AddAsync(model);
        return AppResult.Status200OK("新增成功");
    }
    [HttpPost]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> Update([FromBody] QHSEDictionaryModel model)
    {
        await _dictionaryService.UpdateAsync(model);
        return AppResult.Status200OK("编辑成功");
    }
    [HttpPost]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> Delete([FromBody] List<IdInputModel> models)
    {
        await _dictionaryService.DeleteAsync(models.Select(m => m.Id));
        return AppResult.Status200OK("删除成功");
    }
    /// <summary>
    /// 可能后果
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> KNHGList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1009");
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> KNHGList1()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1009");
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 数据来源
    /// </summary>
    [CustomAuthorize("hdv_qhse_data")]
    [HttpGet]
    public async Task<AppResult> EnterSysList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1001");
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> EnterSysList1()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1001");
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 年龄
    /// </summary>
    [CustomAuthorize("hdv_qhse_data")]
    [HttpGet]
    public async Task<AppResult> AGEList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1002");
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> AGEList1()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1002");
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 工龄
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> GLList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1003");
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> GLList1()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1003");
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 检查类型
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> CheckTypeList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1000");
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> CheckTypeList1()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1000");
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 用工性质
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> YGXZList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1004");
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> YGXZList1()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1004");
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 违章原因分析
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> YYFXList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1007");
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> YYFXList1()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1007");
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 隐患原因分析
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> YHYYFXList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1016");
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> YHYYFXList1()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1016");
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 归属部门列表
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> GSBMList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1008");
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> GSBMList1()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1008");
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 隐患级别
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> HazardLevelList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1010");
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> HazardLevelList1()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1010");
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 隐患状态
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> HazardStatusList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1011");
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> HazardStatusList1()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1011");
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 风险等级
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> RiskList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1012");
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> RiskList1()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1012");
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 违章分类
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> ViolationTypeList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1014");
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> ViolationTypeList1()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1014");
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 隐患分类
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> DangerTypeList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1013");
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> DangerTypeList1()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1013");
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 违章隐患标准
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> HavStandardList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1015");
        return AppResult.Status200OK(data: menus);
    }
    /// <summary>
    /// 数据检查方式
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> InspectionMethodList()
    {
        List<QHSEDictionaryModel> menus = await _dictionaryService.GetDictionaryAsync("1017");
        return AppResult.Status200OK(data: menus);
    }
}
